import logging

from selenium.webdriver.chrome import webdriver
from selenium.webdriver.chrome.webdriver import WebDriver
from selenium.webdriver.remote.webelement import WebElement
from selenium.webdriver.support.wait import WebDriverWait

from yizuauto.common.dologs import DoLog

Logger = DoLog().set_get_logger(logging.INFO)


class BasePage():
    def _init_(self,d=None):
       if d is None:
            self.wd=webdriver.WebDriver()
       else:
           self.wd: WebDriver = d
       self.wd.maximize_window()
       self.wd.implicitly_wait(10)


def getElment(self, locater):
    try:
        e: WebElement = WebDriverWait(self.wd, 10, 1).until(lambda x: x.find_element(*locater))
    except Exception as e1:
        Logger.error(f"发生了异常，查找元素失败{locater}", f"错误元素{e1}")
    else:
        Logger.info("f查找元素{locater}成功")
        return e
